﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace proyectoENS
{
    public partial class frmGenerarInformes : Form
    {
        private System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
        public frmGenerarInformes()
        {
            InitializeComponent();
            cbxAño.DataSource = DALCursos.getAños();
        }

        private void frmGenerarInformes_Load(object sender, EventArgs e)
        {
            
            
        }
       
        private void generarGrafico(int idCurso)
        {

            chart1.Series.Clear();
            this.chart1.Series.Add(series1);
            chart1.Series[0].Name = "Aprobados";
            chart1.Series[0].XValueMember = ClassGraphics.getEstadoAlumnosByMaterias(idCurso).Columns["Materia"].ToString();
            chart1.Series[0].YValueMembers = ClassGraphics.getEstadoAlumnosByMaterias(idCurso).Columns["Aprobados"].ToString();
            chart1.Series.Add("Series2");
            chart1.Series[1].Name = "Desaprobados";
            chart1.Series[1].YValueMembers = ClassGraphics.getEstadoAlumnosByMaterias(idCurso).Columns["Desaprobados"].ToString();
            chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
            chart1.ChartAreas["ChartArea1"].AxisY.Interval = 1;
            chart1.DataSource = ClassGraphics.getEstadoAlumnosByMaterias(idCurso);
        }
        private void cbxAño_SelectedIndexChanged(object sender, EventArgs e)
        {
            int tmp = int.Parse(cbxAño.SelectedValue.ToString());
            cbxDivision.DataSource = DALCursos.getDivisiones(tmp);
        }

        private void btnSeleccionar_Click(object sender, EventArgs e)
        {
            generarGrafico((int)((Cursos)cbxDivision.SelectedItem).idCurso);
        }
    }
}
